#!/usr/bin/perl

foreach (split("\n", "c*	c4h2	sh	hs	52.88	0	0	-52.05	1	0	18.46	2	0	306.36	3	0
c*	c4*	sc	c4*	0	0	0	367.6	1	0	-270.18	2	0	581.64	3	0
c*	sc	sc	c*	1763.9	0	0	398	1	0	-2181.6	2	0	505.25	3	0
c*	c4h2	c4h	s*	-251.06	0	0	428.73	1	0	-111.85	2	0	441.27	3	0
c*	c4h2	c4	s*	0	0	0	0	1	0	0	2	0	461.29	3	0
c4h3	c4h	sh	hs	0	0	0	0	1	0	0	2	0	400	3	0
c*	c*	c3o	o	2035.58	0	0	-736.9	1	0	57.84	2	0	-293.23	3	0
c*	c*	c3ho	o	2035.58	0	0	-736.9	1	0	57.84	2	0	-293.23	3	0
c*	c*	c3mo	o	2035.58	0	0	-736.9	1	0	57.84	2	0	-293.23	3	0
c*	c*	os	c*	0	0	0	725.35	1	0	-163.75	2	0	558.20	3	0
c*	c4	c4h2	c*	0	0	0	0	1	0	0	2	0	461.29	3	0
c*	c4	oh	ho	0	0	0	0	1	0	0	2	0	163.56	3	0
c*	c4h	c4h	c*	-251.06	0	0	428.73	1	0	-111.85	2	0	441.27	3	0
c*	c4h	c4h2	c*	-251.06	0	0	428.73	1	0	-111.85	2	0	441.27	3	0
c*	c4h	oh	ho	215.96	0	0	197.33	1	0	31.46	2	0	-173.92	3	0
c*	c4h2	c4h2	c*	0	0	0	355.03	1	0	-68.19	2	0	791.32	3	0
c*	c4h2	c4h2	oh	0	0	0	176.62	1	0	-53.34	2	0	769.93	3	0
c*	c4h2	c4h2	os	0	0	0	176.62	1	0	-53.34	2	0	769.93	3	0
c*	c4h2	oh	ho	0	0	0	209.82	1	0	-29.17	2	0	187.93	3	0
c*	c4h2	c3h	c3*	688.5	0	0	86.36	1	0	-109.77	2	0	-282.24	3	0
c*	c3h	c3h	c*	0	0	0	127	1	0	6540	2	0	-127	3	0
c3*	c3*	c3o	o	823.03	0	0	-47.91	1	0	-773.13	2	0	1.99	3	0	
c3*	c3*	c3o	os	823.03	0	0	47.91	1	0	-773.13	2	0	-1.99	3	0
c3*	c3*	os	c4*	895.2	0	0	417.41	1	0	1373.14	2	0	30.19	3	0
c3*	os	c4*	c4*	665.84	0	0	-751.83	1	0	538.95	2	0	-22.1	3	0	51.27	4	0	
c3*	os	c3o	o	4716	0	0	2194	1	0	2059	2	0	-153.4	3	0
c3h	os	c3o	c4*	-14.48	0	0	993.1	1	0	520.7	2	0	-138.5	3	0
c4*	os	c3o	o	1820.74	0	0	-417.41	1	0	-1373.14	2	0	-30.19	3	0
c4*	os	c3o	c*	1820.74	0	0	417.41	1	0	-1373.14	2	0	30.19	3	0
ca*	c4*	c4h2	c*	0	0	0	0	1	0	131	2	180	0	3	0
ca*	c4*	c3h	c*	0	0	0	0	1	0	167	2	300	0	3	0
ca*	ca*	ca*	ca*	0	0	0	0	1	0	1560.07	2	180	0	3	0
m	ca*	ca*	ca*	0	0	0	0	1	0	1560.07	2	180	0	3	0
m	m	ca*	ca*	0	0	0	0	1	0	1560.07	2	180	0	3	0
oh	c4h2	c4h2	oh	503.24	0	0	0	1	0	-251.62	2	0	1006.47	3	0
os	c3o	c3*	c3*	436.47	0	0	49.4025	1	0	386.565	2	0	0.4975	3	0
os	c4h2	c4h2	os	503.24	0	0	0	1	0	-251.62	2	0	1006.47	3	0
os	c4h2	c4h2	oh	503.24	0	0	0	1	0	-251.62	2	0	1006.47	3	0
c*	c4*	no	on	127.09	0	0	-41.4	1	0	14.5	2	0	-19.1	3	0	-8.03	4	0	-2.91	5	0	-0.95	6	0
hc	c4*	c4*	c*	0	0	0	0	1	0	0	2	0	854	3	180
hc	c4*	c4*	no	454.32	0	0	-219	1	0	-63.7	2	0	4.98	3	0	-8.19	4	0	-2.63	5	0	-0.78	6	0
hc	c4*	c4*	n3*	221.34	0	0	481	1	0	-150	2	0	-115	3	0	0.57	4	0	0.08	5	0	0.01	6	0
hc	c4*	n3*	hn	422.74	0	0	-109	1	0	-12.5	2	0	-102	3	0	-0.21	4	0	-0.03	5	0
hc	c4*	n3*	c4*	357.78	0	0	-37	1	0	-4.69	2	0	-142	3	0	-0.1	4	0	0.01	5	0
hc	c4*	no	on	260.72	0	0	-40.8	1	0	-80.4	2	0	-41.	3	0	-16.	4	0	-5.44	5	0	-1.68	6	0
c4*	c*	n3*	hn	352.2	0	0	47.8	1	0	-105	2	0	-105	3	0
c4*	n3*	c4*	c*	6443.6	0	0	-2188	1	0	-1381	2	0	-890	3	0	-329	4	0	-137	5	0	-52.6	6	0
c4*	c4*	c4*	n3*	221.34	0	0	481	1	0	-150	2	0	-115	3	0	0.57	4	0	0.08	5	0	0.01	6	0
c*	c4*	c3mo	n3*	221.34	0	0	481	1	0	-150	2	0	-115	3	0	0.57	4	0	0.08	5	0	0.01	6	0
hc	c4*	c3mo	n3*	221.34	0	0	481	1	0	-150	2	0	-115	3	0	0.57	4	0	0.08	5	0	0.01	6	0
c*	c4*	c3mo	o	221.34	0	0	481	1	0	-150	2	0	-115	3	0	0.57	4	0	0.08	5	0	0.01	6	0
hc	c4*	c3mo	o	221.34	0	0	481	1	0	-150	2	0	-115	3	0	0.57	4	0	0.08	5	0	0.01	6	0
hn	n3*	c3mo	o	1119	0	0	-163	1	0	629	2	0	0	3	0")) {
  @arg = split(" ");
  @arg[0 .. 3] = reverse(@arg[0 .. 3]) if (@arg[2] lt @arg[1]);
  @arg[0 .. 3] = @arg[1,2,0,3];
  push(@sort, join("\t", @arg));
}

foreach (sort(@sort)) {
  @arg = split("\t");
  @arg[0 .. 3] = @arg[2,0,1,3];
  print(join("\t", @arg), "\n");
}

